import { OpMakerInfoIM, OpMakerInfoPM, OpMakerInfoPPM, OpMakerInfoLRM } from '@/model/operations/makerinfo.model';
import { defHttp } from '@/utils/http/axios';
import { formatToDateTime } from '@/utils/core/DateUtil';
import dayjs from 'dayjs';

const basicApi = '/operations/admin/makerinfo';

enum Api {
  LIST = basicApi + '/list',
  GET = basicApi + '/',
  ADD = basicApi,
  EDIT = basicApi,
  DEL_BATCH = basicApi + '/batch/',
  EXPORT = basicApi + '/export',
}

/** 查询厂商信息列表 */
export const listOpMakerInfoApi = (params?: OpMakerInfoPPM) =>
  defHttp.get<OpMakerInfoLRM>({ url: Api.LIST, params });

/** 查询厂商信息详细 */
export const getOpMakerInfoApi = (id: string) =>
  defHttp.get<OpMakerInfoIM>({ url: Api.GET, params: id });

/** 新增厂商信息 */
export const addOpMakerInfoApi = (params: OpMakerInfoIM) =>
  defHttp.post({ url: Api.ADD, params });

/** 修改厂商信息 */
export const editOpMakerInfoApi = (params: OpMakerInfoIM) =>
  defHttp.put({ url: Api.EDIT, params });

/** 删除厂商信息 */
export const delOpMakerInfoApi = (ids: string | string[]) =>
  defHttp.delete({ url: Api.DEL_BATCH, params: ids.toString() });

/** 导出厂商信息 */
export const exportOpMakerInfoApi = async (params?: OpMakerInfoPM) =>
  defHttp.export<any>(
    { url: Api.EXPORT, params: params },
    '厂商信息_' + formatToDateTime(dayjs()) + '.xlsx',
  );
